package com.chapter16.Runnable_;

/**
 * @author 宋鑫宇
 * @version 1.0
 * 实现 Runnable 接口创建线程（匿名内部类形式）
 */
public class Runnable03 {
    public static void main(String[] args) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println("子线程1  " + i);
                }
            }
        }).start();

        //用lambda表达式简化方式
        new Thread(() -> {
            for (int j = 0; j < 10; j++) {
                System.out.println("子线程2  " + j);
            }
        }).start();


        for (int i = 0; i < 10; i++) {
            System.out.println("主线程" + i);
        }
    }
}
